package com.simplenix.nicasio.admin.tray;

import com.simplenix.nicasio.admin.eb.User;
import com.simplenix.nicasio.mb.Session;
import com.simplenix.nicasio.misc.StrUtil;
import com.simplenix.nicasio.navig.TrayItem;
import com.simplenix.nicasio.sys.SystemDef;
import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author fronald
 */
public class UsuNameItem implements TrayItem {

	public String getHtml(HttpServletRequest request) {
		String rtn = "";
		User u = (User) request.getSession().getAttribute(Session.CURRENT_USER);
		if (u != null) {
			String desc = StrUtil.nvl(u.getName());
			if (desc.equals("")) {
				desc = StrUtil.nvl(u.getLogin());
			}
			rtn += "<a href='" + SystemDef.getInstance().getContextPath() + "/admin/users/profile.htm'>" + desc + "</a> | <a href='" + SystemDef.getInstance().getContextPath() + "/admin/misc/logout.htm'>Logout</a>";
		}
		return rtn;
	}

}
